package br.ebula.apl.controladores;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.ebula.apl.dto.DTOListaBulas;
import br.ebula.apl.fachada.FachadaListaBulas;

public class ServletListaBulas extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8351513903256743920L;

	@Override
	public void doPost(HttpServletRequest req, HttpServletResponse resp) {
		doGet(req,resp);
	}
	
	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse resp){
		
		DTOListaBulas dto = new DTOListaBulas();
		dto.retiraFiltro(req);
		dto.retiraMensagem(req);
		
		FachadaListaBulas fachada = new FachadaListaBulas();
		fachada.listaBulas(dto);
		
		try {
			req.setAttribute("lista_bulas", dto);
			RequestDispatcher r = req.getRequestDispatcher("apresentacao/lista_bulas.jsp");
			r.forward(req, resp);
		} catch (ServletException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
